package demo1;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/hello")
public class ControllerServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        resp.setContentType("text/html; charset=UTF-8");
        resp.getWriter().println("第一个servlet");
        String id = this.getServletContext().getInitParameter("id");
        resp.getWriter().println("参数="+id);
        Object age = this.getServletContext().getAttribute("age");
        resp.getWriter().println("age="+age);
        StringBuffer requestURL = req.getRequestURL();
        resp.getWriter().println("requestURL="+requestURL);
        resp.getWriter().println("getMethod="+req.getMethod());
        resp.getWriter().println("getServletPath="+req.getServletPath());
        resp.setStatus(Integer.parseInt("222"));
        resp.sendError(Integer.parseInt("222"),"ssss");

    }
}
